package cn.wolfcode.crm.Service.impl;

import cn.wolfcode.crm.Service.ISystemDictionaryService;
import cn.wolfcode.crm.domain.SystemDictionary;
import cn.wolfcode.crm.mapper.SystemDictionaryMapper;
import cn.wolfcode.crm.query.SystemDictionaryQuery;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemDictionaryServiceImpl implements ISystemDictionaryService {
    @Autowired
    private SystemDictionaryMapper systemDictionaryMapper;
    @Override
    public int insert(SystemDictionary record) {
        return systemDictionaryMapper.insert(record);
    }

    @Override
    public List<SystemDictionary> selectAll() {
        return systemDictionaryMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(SystemDictionary record) {
        return systemDictionaryMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageInfo<SystemDictionary> queryForList(SystemDictionaryQuery qo) {
        //查询结果集,并告诉mybatis要进行分页
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<SystemDictionary> list = systemDictionaryMapper.queryForList(qo);
        return new PageInfo<>(list);
    }

    @Override
    public SystemDictionary get(Long parentId) {
        return systemDictionaryMapper.selectByPrimaryKey(parentId);
    }
}
